using System;
using System.Collections.Generic;
using TestCases.CompareAssert.Core.Comparers.Interfaces;
using TestCases.CompareAssert.Core.Compositions;
using TestCases.CompareAssert.Core.Interfaces;
using TestCases.CompareAssert.Core.Builders;
using TestCases.Utils.Pairs;

namespace TestCases.CompareAssert.Core.Factories
{
    public class FullBuilderFactory : IResultBuilderFactory
    {
        private static readonly FullBuilderFactory _instance = new FullBuilderFactory();

// Explicit static constructor to tell C# compiler not to mark type as beforefieldinit
// ReSharper disable EmptyConstructor
        static FullBuilderFactory()
// ReSharper restore EmptyConstructor
        {
        }

        private FullBuilderFactory()
        {
        }

        public static FullBuilderFactory Instance
        {
            get { return _instance; }
        }


        public IResultBuilder ForSimpleResult(IObjectComparer comparer, CompareStatus status, IPair<IComparerObject, IComparerObject> pair)
        {
            return new ResultBuilder(comparer, status, pair);
        }

        public IResultBuilder ForDecoratorResult(IObjectComparer comparer, CompareStatus status, IPair<IComparerObject, IComparerObject> pair, IResultProvider child)
        {
            return new ResultBuilder(comparer, status, pair, child.GetResult());
        }

        public IResultBuilder ForCompositeResult<T>(IObjectComparer comparer, CompareStatus status, IPair<IComparerObject, IComparerObject> pair, IList<T> children) where T: IResultProvider
        {
            return new ResultBuilder(comparer, status, pair, children.GetResults());
        }

    }
}